//
// Created by w on 17-7-9.
//

#ifndef MYSQLPOOL_MYSQLPOOL_H
#define MYSQLPOOL_MYSQLPOOL_H

#include <mysql.h>
#include <malloc.h>
#include <pthread.h>

#define CLIENTS_NUMBER 1
#define IS_POOL 1
#define LOG printf
#define _debug printf

//释放和锁定的锁
pthread_mutex_t mutex;

int _number = 0;

typedef struct _mysql_client_queue{
    int use;
    int key;
    MYSQL *client;
    struct _mysql_client_queue *next;
} mysql_client_queue;

MYSQL  *mysql_clients[CLIENTS_NUMBER];

mysql_client_queue *MYSQL_client_queue;

mysql_client_queue* initClientQueues(int number);
mysql_client_queue* initClientQueue();
mysql_client_queue *getFreeQueue();
void freeQueue(mysql_client_queue *queue);

void freeMysql();
int initMysqlClient(MYSQL** mysql);



#endif //MYSQLPOOL_MYSQLPOOL_H
